% function plot_cavity_votocity

% plot votocity here:
d_wo = d-2;
len = 0;
for tri = 1:posT
    len = len + (d_wo(tri)+1)*(d_wo(tri)+2)/2;
end
c_wo = zeros(len,1);
dofs_wo = zeros(posT,2);
pos = 1;
for tri = 1:posT
    V1=V(T(tri,1),:);V2=V(T(tri,2),:);V3=V(T(tri,3),:);
    A = [1,1,1;V1(1) V2(1) V3(1);V1(2) V2(2) V3(2)];
    nx = A\[0;1;0]; ny = A\[0;0;1];
    tri_dof = get_tri_dof(dofs,tri);
    c_loc = c(tri_dof);
    degree = d(tri);
    c_x = degree*de_cast_step(c_loc,degree,nx(1),nx(2),nx(3),desc);
    c_xx = (degree-1)*de_cast_step(c_x,degree-1,nx(1),nx(2),nx(3),desc);
    c_y = degree*de_cast_step(c_loc,degree,ny(1),ny(2),ny(3),desc);
    c_yy = (degree-1)*de_cast_step(c_y,degree-1,ny(1),ny(2),ny(3),desc);
    n_dof_tri = (d_wo(tri)+1)*(d_wo(tri)+2)/2;
    c_wo(pos:pos+n_dof_tri-1) = c_xx+c_yy;
    dofs_wo(tri,:) = [pos,pos+n_dof_tri-1];
    pos = pos+n_dof_tri;
end % finish getting the coefficient of voticity in B-coefficient
Z_wo = geval(dofs_wo,V,T,posT,d_wo,c_wo,X(:),Y(:));
L_wo=[-180:40:20 -8:0.4:8 20:40:180];
figure;contour(X,Y,reshape(Z_wo,size(X)),L_wo);

% png_file = sprintf('E:\\workspace\\10.thesis\\doc\\chap5\\vorticity_re%d.png',Renold_good);
% eps_file = sprintf('E:\\workspace\\10.thesis\\doc\\chap5\\vorticity_re%d.eps',Renold_good);
% print('-dpng', png_file);
% print ('-depsc',eps_file);